<script>
	$(document).ready(function(){
        $('input[type="radio"]').click(function(){		
            if($(this).attr("value")=="Wali"){
                $("div#hub").show('slow');
            }
            if($(this).attr("value")=="Ayah"){
               $("div#hub").hide('slow');
            }
			if($(this).attr("value")=="Ibu"){
               $("div#hub").hide('slow');
            }
        });
    });
</script>

      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="myModalLabel">Edit Orang Tua/Wali</h4>
      </div>
      <div class="modal-body">

		<?php 
			echo form_open_multipart('mr_ortuwali/update', array('class' => 'form-horizontal', 'role' => 'form')); 
			foreach ($list as $row){ 
		?>
		<input type="hidden" name="id_mr_ortuwali" value="<?php echo $row->id_mr_ortuwali; ?>">

		<div class="form-group">
		<label class="col-sm-3 control-label">Hubungan</label>
		<div class="col-sm-9">
			<label class="radio-inline">
				<input type="radio" name="hubungan" value="Ayah" <?php if ($row->hubungan == 'Ayah'){echo "checked";} ?>>
				Ayah
			</label>

			<label class="radio-inline">
				<input type="radio" name="hubungan" value="Ibu"  <?php if ($row->hubungan == 'Ibu'){echo "checked";} ?>>
				Ibu
			</label>
			
			<label class="radio-inline">
				<input type="radio" name="hubungan" id="wali" value="Wali"  <?php if ($row->hubungan == 'Wali'){echo "checked";} ?>>
				Wali
			</label>
		</div>
	  </div>
	  
		<div id="hub" <?php if ($row->hubungan <> 'Wali'){echo ' style="display:none;" ';} ?>>
		<div class="form-group">
			<label class="col-sm-3 control-label">Hubungan Wali</label>
			<div class="col-sm-9">
				<input type="text" name="hub_wali" class="form-control input-sm" placeholder="Hubungan Wali" value="<?php echo $row->hub_wali; ?>">
			</div>
		</div>
		</div>
		
		<div class="form-group">
			<label class="col-sm-3 control-label">Nama Lengkap</label>
			<div class="col-sm-9">
				<input type="text" name="nama" class="form-control input-sm" placeholder="Nama Lengkap" value="<?php echo $row->nama; ?>">
			</div>
		</div>
		
		<div class="form-group">
			<label class="col-sm-3 control-label">Alamat</label>
			<div class="col-sm-9">
				<textarea name="alamat" class="form-control input-sm" rows="3" placeholder="Alamat Lengkap"> <?php echo $row->alamat; ?></textarea>
			</div>
		</div>

		<div class="form-group">
			<label class="col-sm-3 control-label">Kelurahan</label>
			<div class="col-sm-5">
				<input type="text" name="kel" class="form-control input-sm" placeholder="Kelurahan" value="<?php echo $row->kel; ?>">
			</div>
		</div>	

		<div class="form-group">
			<label class="col-sm-3 control-label">Kecamatan</label>
			<div class="col-sm-5">
				<input type="text" name="kec" class="form-control input-sm" placeholder="Kecamatan" value="<?php echo $row->kec; ?>">
			</div>
		</div>			
			
		<div class="form-group">
			<label class="col-sm-3 control-label">No. Tlp</label>
			<div class="col-sm-9">
			  <input type="text" name="tlp" class="form-control input-sm" placeholder="No. Tlp" value="<?php echo $row->tlp; ?>">
			</div>
		</div>
		
		<div class="form-group">
			<label class="col-sm-3 control-label">Email</label>
			<div class="col-sm-5">
			  <input type="text" name="email" class="form-control input-sm" placeholder="Email" value="<?php echo $row->email; ?>">
			</div>
		</div>
		
		<div class="form-group">	
			<label class="col-sm-3 control-label">Pekerjaan</label>
			<div class="col-sm-7">
				<select name="id_mr_pekerjaan" class="form-control input-sm">
					<?php 
					foreach ($list_pekerjaan->result() as $row_pekerjaaan){ 
					
						if($row_pekerjaaan->id_mr_pekerjaan==$list[0]->id_mr_pekerjaan){
						?>
							<option selected value="<?php echo $row_pekerjaaan->id_mr_pekerjaan; ?>"><?php echo  $row_pekerjaaan->pekerjaan; ?></option>
						<?php
						}else{
						?>
							<option value="<?php echo $row_pekerjaaan->id_mr_pekerjaan; ?>"><?php echo  $row_pekerjaaan->pekerjaan; ?></option>							
						<?php
						}
					}; 
					?>
				</select>
			</div>
		</div>
		
		<div class="form-group">
			<label class="col-sm-3 control-label">Jabatan</label>
			<div class="col-sm-5">
			  <input type="text" name="jabatan" class="form-control input-sm" placeholder="Jabatan" value="<?php echo $row->jabatan; ?>">
			</div>
		</div>
		
		<div class="form-group">	
			<label class="col-sm-3 control-label">Gaji</label>
			<div class="col-sm-7">
				<select name="id_mr_gaji" class="form-control input-sm">
					<?php 
					foreach ($list_gaji->result() as $row_gaji){ 
						if($row_gaji->id_mr_gaji==$list[0]->id_mr_gaji){
						?>
							<option selected value="<?php echo $row_gaji->id_mr_gaji; ?>"><?php echo  $row_gaji->gaji; ?></option>
						<?php
						}else{
						?>
							<option value="<?php echo $row_gaji->id_mr_gaji; ?>"><?php echo  $row_gaji->gaji; ?></option>
							
						<?php
						} 
					}; 
					?>
				</select>
			</div>
		</div>
		
		<div class="form-group">
			<label class="col-sm-3 control-label">Kantor</label>
			<div class="col-sm-7">
			  <input type="text" name="kantor" class="form-control input-sm" placeholder="Nama Kantor" value="<?php echo $row->kantor; ?>">
			</div>
		</div>
		
		<div class="form-group">
			<label class="col-sm-3 control-label">Alamat Kantor</label>
			<div class="col-sm-9">
				<textarea name="alamat_kantor" class="form-control input-sm" rows="3" placeholder="Alamat Kantor"><?php echo $row->alamat_kantor; ?></textarea>
			</div>
		</div>
		
		<div class="form-group">
			<label class="col-sm-3 control-label">No. Tlp. Kantor</label>
			<div class="col-sm-5">
			  <input type="text" name="tlp_kantor" class="form-control input-sm" placeholder="No. Tlp. Kantor"  value="<?php echo $row->tlp_kantor; ?>">
			</div>
		</div>
		
		<div class="form-group">
			<label class="col-sm-3 control-label">No. Fax Kantor</label>
			<div class="col-sm-5">
			  <input type="text" name="fax_kantor" class="form-control input-sm" placeholder="No. Fax Kantor"  value="<?php echo $row->fax_kantor; ?>">
			</div>
		</div>
		
		<div class="form-group">	
			<label class="col-sm-3 control-label">Pendidikan Terakhir</label>
			<div class="col-sm-7">
				<select name="id_mr_pendidikan" class="form-control input-sm">
					<?php 
					foreach ($list_pendidikan->result() as $row_pendidikan){ 
						if($row_pendidikan->id_mr_pendidikan==$list[0]->id_mr_pendidikan){
						?>
							<option selected value="<?php echo $row_pendidikan->id_mr_pendidikan; ?>"><?php echo  $row_pendidikan->pendidikan; ?></option>
						<?php
						}else{
						?>
							<option value="<?php echo $row_pendidikan->id_mr_pendidikan; ?>"><?php echo  $row_pendidikan->pendidikan; ?></option>						
						<?php
						}
					}; 
					?>
				</select>
			</div>
		</div>
		
		<div class="form-group">
		<label class="col-sm-3 control-label">Kewarganegaraan</label>
		<div class="col-sm-9">
			<?php
				if ($row->warga != ''){
				?>
					<label class="radio-inline">
						<input type="radio" name="warga" value="WNI" <?php if ($row->warga == 'WNI'){echo "checked";} ?>>
						WNI
					</label>

					<label class="radio-inline">
						<input type="radio" name="warga" value="WNA" <?php if ($row->warga == 'WNA'){echo "checked";} ?>>
						WNA
					</label>
				<?php
				}else{
				?>
					<label class="radio-inline">
						<input type="radio" name="warga" value="WNI" checked>
						WNI
					</label>

					<label class="radio-inline">
						<input type="radio" name="warga" value="WNA">
						WNA
					</label>
				<?php
				}
			?>
		</div>
	  </div>
	  
	  <div class="form-group">	
			<label class="col-sm-3 control-label">Agama</label>
			<div class="col-sm-9">
					<?php 
					if($list[0]->id_mr_agama != ''){
						foreach ($list_agama->result() as $row){ 
							if($row->id_mr_agama==$list[0]->id_mr_agama){
							?>
								<label class="radio-inline">
									<input type="radio" name="id_mr_agama" value="<?php echo $row->id_mr_agama; ?>" checked>
									<?php echo $row->agama; ?>
								</label>
							<?php
							}else{
							?>
								<label class="radio-inline">
									<input type="radio" name="id_mr_agama" value="<?php echo $row->id_mr_agama; ?>">
									<?php echo $row->agama; ?>
								</label>
							<?php
							}
						}; 
					}else{
						foreach ($list_agama->result() as $row){ 
							if($row->id_mr_agama == 3){
							?>
								<label class="radio-inline">
									<input type="radio" name="id_mr_agama" value="<?php echo $row->id_mr_agama; ?>" checked>
									<?php echo $row->agama; ?>
								</label>
							<?php
							}else{
							?>
								<label class="radio-inline">
									<input type="radio" name="id_mr_agama" value="<?php echo $row->id_mr_agama; ?>">
									<?php echo $row->agama; ?>
								</label>
							<?php
							}
						};
					}
					?>
			</div>
		</div>
								
		<div class="form-group">
		<div class="col-sm-offset-3 col-sm-9">
			<button type="submit" class="btn btn-primary btn-sm">Update</button>
			<button type="reset" class="btn btn-danger btn-sm" data-dismiss="modal" aria-hidden="true">Batal</button>
		</div>
		</div>
		<?php 
			}
			echo form_close();
		?>

      </div>   